package com.leetcode;

public class ReverseInteger
{
	public static void main(String[] args)
	{
		ReverseInteger ri = new ReverseInteger();
		System.out.println(ri.reverseInteger(-1234));
	}

	public int reverseInteger(int x)
	{
		boolean negative = false;
		if (x < 0)
		{
			x = -x;
			negative = true;
		}
		int m = 0;

		while (x != 0)
		{
			m = m * 10 + x % 10;
			x /= 10;
		}

		return negative ? -m : m;
	}
}
